﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Collections;
namespace TypingG
{
    
    class AccInfo
    {
        private static string accName = "NoName";
        private static string pass="";
        private static string level="Vỡ Lòng";
        private static string exp="0";

        //
        private static int willHaveExp;
        public static void start(int _index)
        {
            DataSet ds = SQLServer.ShowData(new System.Windows.Forms.DataGridView(), "CapDoTaiKhoan");
            accName = ds.Tables[0].Rows[_index][0].ToString();
            pass = ds.Tables[0].Rows[_index][1].ToString();
            level = ds.Tables[0].Rows[_index][2].ToString();
            exp = ds.Tables[0].Rows[_index][3].ToString();
            
        }
        public static void increaseEXP(int _exp)
        {
            Int64 e = Convert.ToInt64(exp);
            e += _exp;
            exp = Convert.ToString(e);
            checkLvUP();
        }
        public static void decreaseEXP(int _exp)
        {
            Int64 e = Convert.ToInt64(exp);
            e -= _exp;
            exp = Convert.ToString(e);
               
        }

        public static void ChangePass(string _newPass)
        {
            pass = _newPass;
        }
        public static void checkLvUP()
        {
            ArrayList UpE = new ArrayList();
            UpE.Add("0");  
            UpE.Add("5000");  //up to Nâng Cao
            UpE.Add("15000"); //up to Đường Phố
            UpE.Add("50000"); //up to Chuyên Nghiệp
            UpE.Add("150000"); //up to Siêu Chuyên Nghiệp
            UpE.Add("500000");//up to Nghiệp Dư
            UpE.Add("1500000");//up to Cao thủ
            UpE.Add("50000000");//up to Siêu Cao Thủ
            UpE.Add("5000000000");
            ArrayList UpLV = new ArrayList();
            UpLV.Add("Vỡ Lòng");
            UpLV.Add("Nâng Cao");
            UpLV.Add("Đường Phố");
            UpLV.Add("Chuyên Nghiệp");
            UpLV.Add("Siêu Chuyên Nghiệp");
            UpLV.Add("Nghiệp Dư");
            UpLV.Add("Cao Thủ");
            UpLV.Add("Siêu Cao Thủ");
            UpLV.Add("Huyền Thoại");
            int index = 0;
            for (int i = 0; i < UpE.Count; i++)
            {
                if (level == UpLV[i].ToString())
                {
                    index = i;
                    if (Convert.ToUInt64(exp) >= Convert.ToUInt64(UpE[i+1].ToString()))
                    {
                        index = i + 1;
                        System.Windows.Forms.MessageBox.Show("levelup");
                    }
                }
            }
            level = UpLV[index].ToString();
            //luu vao sql
            SQLServer.updateID(accName,level, exp);

        }
        public static ArrayList SaveAcc()
        {

            ArrayList arr = new ArrayList();
            arr.Add(pass);
            arr.Add(level);
            arr.Add(exp);
            return arr;
        }
        //Get or set 
        public static string AccountName
        {
            get
            {
                return accName;
            }
            set
            {
                accName = value;
            }
        }
        public static string Level
        {
            get
            {
                return level;
            }
            set
            {
                level = value;
            }
        }
        public static string EXP
        {
            get
            {
                return exp;
            }
            set
            {
                exp = value;
            }
        }
        public static int WILLHAVEEXP
        {
            get
            {
                return willHaveExp;
            }
            set
            {
                willHaveExp = value;
            }
        }
    }
}
